<template>
  <div class="box">
    <div class="form">
      <div class="display"> {{ text }} </div>
      <div class="input">
        <input
          v-model="text"
          placeholder="Enter an activity.."
        />
      </div>
      <!-- confirm -->
      <!-- cancel -->
      <!-- collection -->
      <div class="button">
        <el-button
          type="danger"
          plain
          @click="addData(text)"
        ><el-icon
            size="14px"
            style="margin-right: 5px"
          >
            <Select />
          </el-icon>
          添加
        </el-button>
        <el-button
          type="danger"
          plain
          @click="deleteData(index)"
        >
          <el-icon>
            <el-icon
              size="14px"
              style="margin-right: 5px"
            >
              <Delete />
            </el-icon>
          </el-icon>
          删除未完成
        </el-button>
        <el-button
          type="danger"
          plain
          @click="deleteData3(text)"
        >
          <el-icon>
            <el-icon>
              <el-icon
                size="14px"
                style="margin-right: 5px"
              >
                <Star />
              </el-icon>
            </el-icon>
          </el-icon>
          删除已完成
        </el-button>
      </div>
      <div class="list">
        <div
          class="add"
          v-for="(item, index) in list"
          :key="index"
        >
          {{ item }}
          <div>
            <el-button
              type="danger"
              :icon="Delete"
              disabled
              circle
              @click="goodData(index)"
            ><el-icon><Select /></el-icon></el-button>
            <el-button
              type="danger"
              :icon="Delete"
              circle
              @click="cancelData(index)"
            >
              <el-icon>
                <Delete />
              </el-icon>
            </el-button>
          </div>
          <!-- <li>{{ item }}<button @click="cancelData(index)"></button></li> -->
        </div>
        <div class="list-title">
          <div class="title">
            <el-icon size="20px">
              <StarFilled />
            </el-icon>
          </div>
        </div>
        <div
          class="add"
          v-for="(item, index) in demo2"
          :key="index"
        >
          {{ item }}
          <div>
            <el-button
              type="danger"
              :icon="Delete"
              circle
              @click="goodData(index)"
            ><el-icon><Select /></el-icon></el-button>
            <el-button
              type="danger"
              :icon="Delete"
              circle
              @click="deleteData2(index)"
            ><el-icon>
                <Delete />
              </el-icon>
            </el-button>
          </div>
          <!-- <el-button type="danger" :icon="Delete" circle /> -->
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      text: "",
      demo2: [],
      list: [],
    };
  },
  methods: {
    addData(text) {
      console.log(text);
      this.demo2.push(text);
    },
    deleteData(index) {
      this.demo2.splice(index);
    },
    deleteData2(index) {
      this.demo2.splice(index, 1);
    },
    deleteData3(index) {
      // this.list.push(this.demo2[index]);
      this.list.splice(index);
    },
    goodData(index) {
      this.list.push(this.demo2[index]);
      this.demo2.splice(index, 1);
    },
    collection(index) {
      this.demo2.push(this.textbox[index]);
      this.list.splice(text);
    },
    cancelData(index) {
      this.list.splice(index, 1);
    },
  },
};
</script>

<style>
:focus {
  outline: none;
}

.box {
  position: relative;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form {
  margin-top: 20%;
  width: 80%;
  /* overflow: hidden; */
  height: 300px;
  text-align: center;
  /* background-color: #fca2a255; */
}

.display {
  position: absolute;
  top: 100px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 104, 129, 0.904);
}

.input input {
  padding: 4%;
  width: 92%;
  font-size: 1rem;
  border: 1px solid rgba(255, 104, 129, 0.904);
  border-radius: 5px;
  color: rgba(255, 104, 129, 0.904);
  background-color: rgba(255, 104, 129, 0.038);
}

input::placeholder {
  color: rgba(255, 104, 129, 0.904);
}

.button {
  width: 95%;
  margin: 3% auto;
  margin-bottom: 60px;
  display: flex;
  flex-flow: wrap;
  justify-content: space-between;
}

.button button {
  margin: 0 20px;
  flex: 1;
  height: 30px;
  border: 1px solid rgba(255, 104, 129, 0.904);
  background: none;
  font-size: 0.8rem;
  color: rgba(255, 104, 129, 0.904);
}

.button button:hover {
  background-color: rgba(255, 104, 129, 0.904);
  color: #fff;
}
button {
  font-family: "icomoon";
}

.list-title {
  margin: 30px;
  position: relative;
  border-top: 1px solid rgba(255, 104, 129, 0.062);
  box-shadow: 0px 0px 10px rgba(255, 104, 129, 0.904);
}
.title {
  position: absolute;
  top: -8px;
  width: 100%;
  text-align: center;
  font-family: "icomoon";
  color: rgba(255, 104, 129, 0.904);
}

.add {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px auto;
  padding: 3%;
  width: 92%;
  /* height: 30px; */
  text-align: left;
  line-height: 0px;
  background-color: rgba(255, 104, 129, 0.288);
}
.add:hover {
  background-color: rgba(255, 104, 129, 0.716);
  /* border: 4px solid rgba(255, 104, 129, 0.171); */
}
.add button {
  /* float: right; */
  color: #fff;
  background-color: transparent;
  border-style: none;
  font-size: 18px;
  line-height: 0px;
}

.add button:hover {
  color: rgba(244, 244, 244, 0.904);
}

ul {
  list-style: none;
}

@media (max-width: 500px) {
  .form {
    margin-top: 25%;
  }
  .display {
    top: 50px;
  }
  .button button {
    margin-top: 10px;
  }
}
</style>